package com;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.google.common.util.concurrent.ServiceManager;
import com.log.Scanner;
@Service
public class ServiceClose implements DisposableBean {
	 protected final Logger logger = LoggerFactory.getLogger(getClass());
	 	@Resource(name="piwikProducerServiceManager")
		private ServiceManager piwikProducerServiceManager;
	    @Resource(name="piwikConsumerServiceManager")
	   	private ServiceManager piwikConsumerServiceManager;
	    @Autowired 
	    Scanner scanner;
	 
	@Override
	public void destroy() throws Exception {
		
		piwikProducerServiceManager.stopAsync();
		piwikProducerServiceManager.awaitStopped();
		piwikConsumerServiceManager.stopAsync();
		piwikConsumerServiceManager.awaitStopped();
		scanner.stopAsync();
	}

}
